import {ArticleAll, ArticleRecommend, Feedback} from '@/api'
//准备actions对象——响应组件中用户的动作
const actions = {
    // 获取全部文章
    async getArticleAll(state, pag) {
        let info = await ArticleAll(pag)
        state.commit('setArticleAll', info)
    },
    // 获取每日推荐
    async getArticleRecommend(state) {
        let info = await ArticleRecommend()
        state.commit('setArticleRecommend', info)
    },
    //发送意见反馈
    async sendFeedback(state, obj) {
        let info = await Feedback(obj)
        return info
    },
}
//准备mutations对象——修改state中的数据
const mutations = {
    // 修改全部文章
    setArticleAll(state, info) {
        state.ArticleAll = info
    },
    // 修改每日推荐文章
    setArticleRecommend(state, info) {
        state.ArticleRecommend = info['aecommend_Article']
    },
}
//准备state对象——保存具体的数据
const state = {
    ArticleAll: [],   // 全部文章信息
    ArticleRecommend: [],//每日推荐文章
}

export default {
    actions,
    mutations,
    state,
    namespaced: true
}